package nl.boelen.game.net.packet;

public class Packet10Join extends Packet {

    private static final int packetNumber = 10;
    private String userName;
    private String uniqueKey;
    private int shirtColor;
    private int x;
    private int y;
    private int TCPport;
    private int UDPport;
    private int movingDirection;
    private int maxhp;
    private int hp;

    public Packet10Join(byte[] data) {
        super(packetNumber);
        String[] datas = (readData(data)).split(":");
        this.userName = datas[0];
        this.uniqueKey = datas[1];
        this.shirtColor = Integer.parseInt(datas[2]);
        this.x = Integer.parseInt(datas[3]);
        this.y = Integer.parseInt(datas[4]);
        this.TCPport = Integer.parseInt(datas[5]);
        this.UDPport = Integer.parseInt(datas[6]);
        this.movingDirection = Integer.parseInt(datas[7]);
        this.maxhp = Integer.parseInt(datas[8]);
        this.hp = Integer.parseInt(datas[9]);
    }

    public Packet10Join(String userName, String uniqueKey, int shirtColor, int x, int y, int TCPport, int UDPport, int movingDirection, int maxhp,
            int hp) {
        super(packetNumber);
        this.userName = userName;
        this.uniqueKey = uniqueKey;
        this.shirtColor = shirtColor;
        this.x = x;
        this.y = y;
        this.TCPport = TCPport;
        this.UDPport = UDPport;
        this.movingDirection = movingDirection;
        this.maxhp = maxhp;
        this.hp = hp;
    }

    @Override
    public byte[] getData() {
        return (packetNumber + userName + ":" + uniqueKey + ":" + shirtColor + ":" + x + ":" + y + ":" + TCPport + ":" + UDPport + ":" + movingDirection
                + ":" + maxhp + ":" + hp).getBytes();
    }

    public String getUsername() {
        return userName;
    }

    public String getUniqueKey() {
        return uniqueKey;
    }

    public int getShirtColor() {
        return shirtColor;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getTCPPort() {
        return TCPport;
    }

    public int getUDPPort() {
        return UDPport;
    }

    public int getMovingDirection() {
        return movingDirection;
    }

    public int getMaxhp() {
        return maxhp;
    }

    public int getHp() {
        return hp;
    }
}
